<?php   if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  class filemanager_model extends CI_Model {
var $aaa = '';
var $bbb = 0;
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
        if($lang == 'en')
        {
            $this->en();
        }
        else{
            $this->vi();
        }
        
    }
    function en()
    {
        $this->aaa = 'chuoi';
    }
    function vi()
    {
        $this->bbb = 452;
    }
    
    
    function get_fileId($id,$key)
    {
        $sql = "SELECT i.id, i.title, i.filename, i.catpath, i.modified, i.day_active, t.text FROM filemanager_item As i, filemanager_type As t WHERE i.type = t.id and i.id = ? and i.filename = ?";
        $query = $this->db->query($sql,array($id,$key));
        if($query->num_rows() == 1) return $query->row();
        return false;
    }
    
    function comparison_day($day1,$day2)
    {//so sanh 2 ngay
        $d1 = date_parse(date("Y-m-d H:i:s",$day1));
        $d2 = date_parse(date("Y-m-d H:i:s",$day2));
        
        $flag = array(
            'year'=>0,
            'month'=>0,
            'day'=>0
        );
        $kq = 0;
        
        if($d1['year'] < $d2['year']){
            $flag['year'] = 1;
        }else{
            if($d1['year'] > $d2['year']){
                $flag['year'] = 2;
            }else{
                $flag['year'] = 3;
            }
        }
        
        if($d1['month'] < $d2['month']){
            $flag['month'] = 1;
        }else{
            if($d1['month'] > $d2['month']){
                $flag['month'] = 2;
            }else{
                $flag['month'] = 3;
            }
        }
        
        if($d1['day'] < $d2['day']){
            $flag['day'] = 1;
        }else{
            if($d1['day'] > $d2['day']){
                $flag['day'] = 2;
            }else{
                $flag['day'] = 3;
            }
        }
        
        if($flag['year'] == 1)
        {//ngay 1 be hon ngay 2
            $kq = 0;
        }
        if($flag['year'] == 2)
        {//ngay 1 lon hon ngay 2
            $kq = 1;
        }
        
        if($flag['year'] == 3)
        {//nam = nhau
            if($flag['month'] == 1)//nho hon
                $kq = 0;
            if($flag['month'] == 2)//lon hon
                $kq = 1;
            if($flag['month'] == 3)//==
            {
                if($flag['day'] == 1)
                    $kq = 0;
                if($flag['day'] == 2)
                    $kq = 1;
                if($flag['day'] == 3)
                    $kq = 2;
            }
        }
        //o: be, 1: lon, 2 = nhau
        return $kq;
    }
  }    
?>
